<script type="text/javascript">
	function captchaRefresh()
		{
			$('captcha').src = "'/form-files-directory/' ?>CaptchaSecurityImages.php?width=100&height=40&characters=6&rand="+ Math.random(100);
		}
	function checkFields()
		{
			var name = document.getElementById('name').value;
			var email = document.getElementById('email').value;
			var reason = document.getElementById('reason').value;
			var message = document.getElementById('message').value;
			var security_code = document.getElementById('security_code').value;
			
			
			if ($('errorMsg'))
				{
					$('errorMsg').style.display = 'none';	
				}
//			alert(name  + " " + email + " " + reason + " " + message + " " + security_code);

			var error = 0;
			var errorMsg = '';
			
			if (name.length == 0)
				{
					error = 1;
					errorMsg	+= 'Name field must not be empty<br>';
				}
			if (email.length == 0 )
				{
					error = 1;	
					errorMsg	+= 'E-mail field must not be empty<br>';
				}
			if (reason == '-1')
				{
						error = 1;
						errorMsg += 'Please select a reason<br>';
				}
			if (message.length == 0 )
				{
					error = 1;
					errorMsg +='Message field must not be empty <br>';
				}			
			if (security_code.length == 0)
				{
					error = 1;
					errorMsg +='Security code field must not be empty<br>';
				}
			if ( error == 1)
				{
					$('errorMsg').update(errorMsg);
					$('errorMsg').show();
				}
			else
				{
					new Ajax.Request
						(
							'security_code.php',
								{
									method : 'post',
									onSuccess:	function (transport)
										{
											var response = transport.responseText;	
											if (response != security_code)
												{
													$('errorMsg').innerHTML = 'Security code doesn\'t match'; 
													$('errorMsg').show();	
												}
											else
												{
													new Ajax.Request
														(
															'sendEmail.php',
																{
																	method : 'post',
																	parameters : {name: name, email: email, reason: reason, message: message, security_code: security_code},
																	onSuccess: function (transport)
																		{
																			var response = transport.responseText;
																			tempText = response.split('$$$');
																			$('errorMsg').innerHTML = tempText[0]; 
																			$('errorMsg').show();	
																			if (tempText[1] == 0 )
																				{
																					$('sendButton').disabled = true;
																				}
																		},
																	onFailure: function ()
																		{	
																			$('errorMsg').innerHTML = 'Error retreving the file'; 
																			$('errorMsg').show();	
																		}
																}
														);
												}
										},
									onFailure : function () 
										{
											$('errorMsg').innerHTML = 'Error retreving the file'; 
											$('errorMsg').show();	
										}
								}
						)	
				}
		}	
</script>
<!-- BEGIN: UNIVERSAL FORM BODY, THIS IS WHAT'S "INCLUDED" -->
<?php #########################################################
// Secure and Accessible PHP Contact Form v.2.0 by Mike Cherim
// There should be no need to edit anything in this file
###############################################################
// Get the config and set the form version
//print_r($_SERVER);
    $lock = "on";
	  require_once("gbcf_config.php");
    $form_version = "v.2.0"; 
    $build = "20061125";

// Fix cases to prevent admin config errors
     $gb_possession = strtolower($gb_possession);
     $x_or_html = strtolower($x_or_html);
     $showcredit = strtolower($showcredit);
     $showprivacy = strtolower($showprivacy);

// Possession management conditions begin
if($gb_possession == "pers") {
     $i_or_we = "I";
     $me_or_us = "me";;
     $my_or_our = "my";
} else if ($gb_possession == "org") {
     $i_or_we = "we";
     $me_or_us = "us";
     $my_or_our = "our";
 } else {
     $i_or_we = "I";
     $me_or_us = "me";
     $my_or_our = "my";
}

// X/HTML choice negotiation
if($x_or_html == "xhtml") {
     $x_or_h_br = "<br />";
     $x_or_h_in = " /";
} else if($x_or_html == "html") {
     $x_or_h_br = "<br>";
     $x_or_h_in = "";
} else {
     $x_or_h_br = "<br />";
     $x_or_h_in = " /";
}

// Unique ID generators (random values would require a session)
     $fl = "$form_location";
     $fv = "$form_version";
     $fp = "$gb_possession";
     $fd = date("TOZ");
     $fh = gethostbyaddr( $_SERVER['REMOTE_ADDR'] );
     $form_id = ''.$fd.''.$fp.''.$fl.''.$fv.''.$fh.'';
     $trap1_value = ''.$fp.''.$fv.''.$fh.''.$fl.''.$fd.'';
     $send_value = ''.$fh.''.$fd.''.$fv.''.$fp.''.$fl.'';
     $form_id = strtoupper(trim(rtrim(str_replace(array("&", "/", "#", "\\", ":", "%", "|", "^", ";", "@", "?", "+", "$", ".", "~", "-", "=", "_", " ",), 'Xz7r9e6', $form_id)))); 
     $trap1_value = strtoupper(trim(rtrim(str_replace(array("&", "/", "#", "\\", ":", "%", "|", "^", ";", "@", "?", "+", "$", ".", "~", "-", "=", "_", " ",), 'fi7c41x', $trap1_value)))); 
     $send_value = strtoupper(trim(rtrim(str_replace(array("&", "/", "#", "\\", ":", "%", "|", "^", ";", "@", "?", "+", "$", ".", "~", "-", "=", "_", " ",), '6wPsA3c', $send_value)))); 


// No errors so far? No successes so far? No confirmation? Hmm. Maybe the user needs a contact form
?>
<!-- Form Intro -->
<div>
	<div>Please fill the following details:</div>
  	<label for="name">Enter your full name<?php echo(''.$x_or_h_br.''); ?></label><input tabindex="<?php echo(''.$tab_name.''); ?>" class="med" type="text" name="name" id="name" size="35" maxlength="40" value=""<?php echo(''.$x_or_h_in.''); ?>>
    <label for="email">Enter your email address<?php echo(''.$x_or_h_br.''); ?></label><input tabindex="<?php echo(''.$tab_email.''); ?>" class="med" type="text" name="email" id="email" size="35" maxlength="40" value=""<?php echo(''.$x_or_h_in.''); ?>>
    <label for="reason">Select a contact reason<?php echo(''.$x_or_h_br.''); ?>   </label> 
    <select tabindex="<?php echo(''.$tab_reason.''); ?>" class="med" style="cursor:pointer;" name="reason" id="reason">
    	<option value="-1"  selected="selected">Please make a selection</option> 
				<?php
			    reset($gb_options);
				  while (list(, $gb_opts) = each($gb_options)) {
					echo('<option value="'.$gb_opts.'">'.$gb_opts.'</option>'."\n"); 
					} 
				?>
       </select>

  <div><label for="message">Enter your message<?php echo(''.$x_or_h_br.''); ?></label><textarea class="textbox" rows="12" cols="35" name="message" id="message"></textarea></div>
	<div style="float: left;padding-bottom: 10px;">
		<label for="security_code">Security Code: </label><input id="security_code" class="med" name="security_code" type="text" />
	</div>
	<div style="float: left;padding-left: 30px;padding-top: 10px;"><img id="captcha" onclick="javascript: captchaRefresh()" src="<?php echo ABS_URL.'form-files-directory/' ?>CaptchaSecurityImages.php?width=100&height=40&characters=6" alt="test here"></div>
	<div style="clear:both"></div>
	<div style="font-size: 1px;height: 10px;">&nbsp;</div>
	<div style="display: none;color: red; font-size: 12px;" id="errorMsg"></div>
	<div style="font-size: 1px;height: 10px;">&nbsp;</div>
	<div style="text-align: center">
  	<input onclick="checkFields()" tabindex="<?php echo(''.$tab_submit.''); ?>" style="cursor:pointer;" class="button" type="button" alt="Click Button to <?php echo(''.$send_button.''); ?>" value="<?php echo(''.$send_button.''); ?>" name="sendButton" id="sendButton" title="Click Button to Submit Form"<?php echo(''.$x_or_h_in.''); ?>> 
	</div>
</div>
